// 引入列表接口
import {
    menuList, roleList, adminList, cateList, specsList, goodsList,
    memberList, bannerList, seckList
} from '../../../request/api.js'
const state = {
    menulist: [],
    rolelist: [],
    adminlist: [],
    catelist: [],
    specslist: [],
    goodslist: [],
    memberlist: [],
    bannerlist: [],
    secklist: []
}
const getters = {
    getMenu(state) {
        return state.menulist
    },
    getRole(state) {
        return state.rolelist
    },
    getAdmin(state) {
        return state.adminlist
    },
    getCate(state) {
        return state.catelist
    },
    getSpecs(state) {
        return state.specslist
    },
    getGoods(state) {
        return state.goodslist
    },
    getMember(state) {
        return state.memberlist
    },
    getBanner(state) {
        return state.bannerlist
    },
    getSeck(state) {
        return state.secklist
    }
}
const mutations = {
    REQ_LIST(state, payload) {
        state.menulist = payload
    },
    REQ_ROLE(state, payload) {
        state.rolelist = payload
    },
    REQ_ADMIN(state, payload) {
        state.adminlist = payload
    },
    REQ_CATE(state, payload) {
        state.catelist = payload
    },
    REQ_SPECS(state, payload) {
        state.specslist = payload
    },
    REQ_GOODS(state, payload) {
        state.goodslist = payload
    },
    REQ_MEMBER(state, payload) {
        state.memberlist = payload
    },
    REQ_BANNER(state, payload) {
        state.bannerlist = payload
    },
    REQ_SECK(state, payload) {
        state.secklist = payload
    }
}
const actions = {
    getMenuAction({ commit }) {
        menuList().then(res => {
            console.log(res, 1111)
            if (res.data.code == 200) {
                commit('REQ_LIST', res.data.list)
            }
        })
    },
    getRoleAction({ commit }) {
        roleList().then(res => {
            if (res.data.code == 200) {
                commit('REQ_ROLE', res.data.list)
            }
        })
    },
    getAdminAction({ commit }) {
        adminList().then(res => {
            if (res.data.code == 200) {
                commit('REQ_ADMIN', res.data.list)
            }
        })
    },
    getCateAction({ commit }) {
        cateList().then(res => {
            if (res.data.code == 200) {
                commit('REQ_CATE', res.data.list)
            }
        })
    },
    getSpecsAction({ commit }) {
        specsList().then(res => {
            if (res.data.code == 200) {
                commit('REQ_SPECS', res.data.list)
            }
        })
    },
    getGoodsAction({ commit }) {
        goodsList().then(res => {
            console.log(res, 'goods')
            if (res.data.code == 200) {
                commit('REQ_GOODS', res.data.list)
            }
        })
    },
    getMemberAction({ commit }) {
        memberList().then(res => {
            console.log(res);
            if (res.data.code == 200) {
                commit('REQ_MEMBER', res.data.list)
            }
        })
    },
    getBannerAction({ commit }) {
        bannerList().then(res => {
            if (res.data.code == 200) {
                console.log(res)
                commit('REQ_BANNER', res.data.list)
            }
        })
    },
    getSeckAction({ commit }) {
        seckList().then(res => {
            if (res.data.code == 200) {
                commit('REQ_SECK', res.data.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    // 开启命名空间
    namespaced: true
}



